<template>
  <div class="tips-container" @mouseover="showTipe = true" @mouseout="showTipe = false">
    <slot></slot>
    <span v-show="showTipe" :class="`tips-style tips-${site}`">
      {{text}}
      <span :class="`tips-arrow tips-arrow-${site}`"></span>
    </span>
  </div>
</template>

<script>
  export default {
    props: ['text', 'site'],
    data () {
      return {
        showTipe: false
      }
    }
  }
</script>

<style scoped>
.tips-container {
  position: relative;
  display: flex;
}
.tips-style {
  position: absolute;
  z-index: 1000;
  background: rgba(0, 0, 0, .8);
  color: #fff;
  font-size: 12px;
  padding: 2px 4px;
  border-radius: 2px;
}
.tips-arrow {
  position: absolute;
  border: 5px solid transparent;
}
/* 顶部 */
.tips-top {
  top: 0;
  transform: translateY(-110%);
}
.tips-arrow-top {
  left: 50%;
  transform: translateX(-50%);
  bottom: -10px;
  border-top-color: rgba(0, 0, 0, .8); 
}
/* 底部*/
.tips-bottom {
  bottom: 0;
  transform: translateY(110%);
}
.tips-arrow-bottom {
  left: 50%;
  transform: translateX(-50%);
  top: -10px;
  border-bottom-color: rgba(0, 0, 0, .8); 
}
/* 右边*/
.tips-right {
  right: 0;
  /* transform: translateX(100%); */
}
.tips-arrow-right {
  top: 50%;
  transform: translateY(-50%);
  left: -10px;
  border-right-color: rgba(0, 0, 0, .8); 
}
/* 左边*/
.tips-left {
  left: 0;
  transform: translateX(-110%);
}
.tips-arrow-left {
  top: 50%;
  transform: translateY(-50%);
  right: -10px;
  border-left-color: rgba(0, 0, 0, .8); 
}
</style>